package com.gym.controller;


import com.github.pagehelper.PageInfo;
import com.gym.pojo.Personaltrainer;
import com.gym.pojo.Train;
import com.gym.service.TrainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class TrainController {
    @Autowired
    private TrainService service;
    @RequestMapping("/insertjl")
    public boolean insertjl(@RequestBody Train train){
        return service.insertjl(train);
    }
    @RequestMapping("/updatejl")
    public boolean updatejl(@RequestBody Train train){
        return service.updatejl(train);
    }
    @RequestMapping("/deletejl")
    public boolean deletejl(int trainid){
        boolean r3=service.deletesj(trainid);
        return service.deletejl(trainid);
    }
    @RequestMapping("/insertsjd")
    public boolean insertsjd(@RequestBody Personaltrainer personaltrainer){
        return service.insertsjd(personaltrainer);
    }
    @RequestMapping("/selectid")
    public Train selectid(int trainid){
        return service.selectjlid(trainid);
    }
    @RequestMapping("/selectjl")
    public Map<String, Object> selectjl(String trainname, int page, int limit){
        PageInfo<Train> pge=service.selectjl(trainname,page,limit);
        System.err.println(pge);
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("code", 0);
        result.put("msg", "");
        result.put("count",pge.getTotal());
        result.put("data", pge.getList());
        return result;
    }
    @RequestMapping("/deletesj")
    public boolean deletesj(int trainid){
        return service.deletesj(trainid);
    }
    @RequestMapping("/deletesjs")
    public boolean deletesjs(int personalId){
        return service.deletesjs(personalId);
    }
    @RequestMapping("selectsjd")
    public List<Train> selectsjd(){
      return service.selectsjd();
    }
    @RequestMapping("selectycx")
    public boolean selectycx(String trainname){
        return service.selectycz(trainname);
    }
}
